package day22;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

public class AccessWeb {
	public static void main(String[] args) {
		Socket s = null;
		try {
			s = new Socket("192.168.0.23", 8080);
			InputStream is = s.getInputStream();
			OutputStream os = s.getOutputStream();
			String request = "GET / HTTP/1.0\n\n";
			os.write(request.getBytes());
			BufferedReader br = new BufferedReader(new InputStreamReader(is));
			PrintWriter pw = new PrintWriter("tomcat.html");
			String str = null;
			while((str=br.readLine())!=null){
				pw.println(str);
			}
			pw.close();
			s.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (s != null)
				try {
					s.close();
				} catch (Exception e) {
				}
		}
	}
}


